<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Info Window Simple</title>

<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">


function detectBrowser() {
  var useragent = navigator.userAgent;
  var mapdiv = document.getElementById("map_canvas");
    
  if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 ) {
    mapdiv.style.width = '100%';
    mapdiv.style.height = '100%';
  } else {
    mapdiv.style.width = '100%';
    mapdiv.style.height = '800px';
  }
}

  function initialize() {
  
    detectBrowser();
    //$selected, $notselected
    var myLatlng = new google.maps.LatLng(13.759127,100.565185);
    var myOptions = {
      scrollwheel: false,
      zoom: 6,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.HYBRID
    }

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    //'http://www.google.com/mapfiles/marker.png'
    var poverty = [
                     <!--[foreach from=$objectArray item=item]-->
                      [
                        '<!--[$item.id]-->', 
                        'house no. : <!--[$item.hou_no]-->', 
                        <!--[$item.hou_latitude]-->,
                         <!--[$item.hou_longitude]-->, 
                        <!--[$item.id]-->,
                      'http://maps.gstatic.com/intl/th_ALL/mapfiles/ms/micons/rangerstation.png'
                      ],
                     <!--[/foreach]-->
                  ];

      setMarkers(map, poverty);
    }

function makeMarker(imageName){
  //alert(imageName);
  var iconImage = new google.maps.MarkerImage(imageName,
      // This marker is 20 pixels wide by 34 pixels tall.
      new google.maps.Size(20, 34),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is at 9,34.
      new google.maps.Point(9, 34));
    return iconImage;
}

function makeShadow(){
  var iconShadow = new google.maps.MarkerImage('http://www.google.com/mapfiles/shadow50.png',
      // The shadow image is larger in the horizontal dimension
      // while the position and offset are the same as for the main image.
      new google.maps.Size(37, 34),
      new google.maps.Point(0,0),
      new google.maps.Point(9, 34));
    return iconShadow;
}
  
  function setMarkers(map, locations) {

    for (var i = 0; i < locations.length; i++) {
      var data = locations[i];
      var myLatLng = new google.maps.LatLng(data[2], data[3]);
     var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          //shadow: makeShadow(),
          icon: data[5],
          //shape: shape,
          title: data[0],
          zIndex: data[4]
      });

                   
    var contentString = data[1];
        
    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });
/*    
    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
    */
    
    google.maps.event.addListener(marker, 'click', infoCallback(infowindow, marker));
    
    }
    
    function infoCallback(infowindow, marker) {
      return function() {
      infowindow.open(map, marker);
  };
}
  }


</script>
<script language="javascript" src="modules/VoteDataCenter/pnajax/ajax_list_person.js"></script>
<!--[ include file="admin_header_menu.htm" ]--><div style="clear:both"></div>
</head>

<!-- Data -->
<fieldset>
  <legend>&nbsp;Person&nbsp;filter&nbsp;</legend>
    <form method=post action="<!--[pnmodurl modname='VoteDataCenter' type='admin' func='list' ctrl='Person']-->">
      <span id="form_province">
        <!--[if $smarty.request.form.pro_id]-->
          <!--[selector_object_array_ex 
                modname="VoteDataCenter" 
                class="Province" 
                field="id" 
                displayField="name"  
                name="form[pro_id]" 
                selectedValue=$smarty.request.form.pro_id
                allValue="0"
                allText="ทุกจังหวัด"
                sort="pro_name"
                onChange="getDistrictByProvinceID()"
          ]-->
        <!--[else]-->
          <!--[selector_object_array_ex 
                modname="VoteDataCenter" 
                class="Province" 
                field="id" 
                displayField="name"  
                name="form[pro_id]" 
                selectedValue=$form.id 
                allValue="0"
                allText="ทุกจังหวัด"
                sort="pro_name"
                onChange="getDistrictByProvinceID()"
          ]-->
        <!--[/if]-->
      </span>
      <span id="form_district">
          <!--[if (isset($smarty.request.form.dis_id) || $smarty.request.form.dis_id == 0) && $smarty.request.form.pro_id]-->
            <!--[selector_object_array_ex modname="VoteDataCenter" 
                    class="District" 
                    field="id" 
                    displayField="name"  
                    name="form[dis_id]" 
                    selectedValue=$smarty.request.form.dis_id
                    queryField = dis_pro_id
                    queryValue = $smarty.request.form.pro_id
                    allValue="0"
                    allText="ทุกอำเภอ"
                    sort="dis_name"
                    onChange="getTambonByDistrictID()"
            ]-->
          <!--[else]-->

          <!--[/if]-->
      </span>
      <span id="form_tambon">
          <!--[if $smarty.request.form.dis_id && $smarty.request.form.pro_id && ($smarty.request.form.tam_id || $smarty.request.form.tam_id == 0 )]-->
            <!--[selector_object_array_ex 
                    modname="VoteDataCenter" 
                    class="Tambon" 
                    field="id" 
                    displayField="name"  
                    name="form[tam_id]" 
                    selectedValue=$smarty.request.form.tam_id
                    queryField = tam_dis_id
                    queryValue = $smarty.request.form.dis_id
                    allValue="0"
                    allText="ทุกตำบล"
                    sort="tam_name"
                    onChange="getVillageByTambonID()"
            ]-->
          <!--[else]-->

          <!--[/if]-->
      </span>
      <span id="form_village">
          <!--[if $smarty.request.form.dis_id && $smarty.request.form.pro_id && $smarty.request.form.tam_id && ($smarty.request.form.vil_id || $smarty.request.form.vil_id == 0 )]-->
            <!--[selector_object_array_ex 
                    modname="VoteDataCenter" 
                    class="Village" 
                    field="id" 
                    displayField="moo"  
                    name="form[vil_id]" 
                    selectedValue=$smarty.request.form.vil_id
                    queryField = vil_tam_id
                    queryValue = $smarty.request.form.tam_id
                    allValue="0"
                    allText="ทุกหมู่"
                    sort="vil_moo"
                    onChange="getHouseNoByVillageID()"
            ]-->
          <!--[else]-->

          <!--[/if]-->
      </span>
      <span id="form_house_no">
          <!--[if $smarty.request.form.dis_id && 
                  $smarty.request.form.pro_id && 
                  $smarty.request.form.tam_id && 
                  $smarty.request.form.vil_id && 
                  ($smarty.request.form.hou_id || $smarty.request.form.hou_id == 0 )
         ]-->
            <!--[selector_object_array_ex 
                    modname="VoteDataCenter" 
                    class="HouseNo" 
                    field="id" 
                    displayField="no"  
                    name="form[hou_id]" 
                    selectedValue=$smarty.request.form.hou_id
                    queryField = hou_vil_id
                    queryValue = $smarty.request.form.vil_id
                    allValue="0"
                    allText="ทุกบ้านเลขที่"
                    sort="hou_no"
            ]-->
          <!--[else]-->

          <!--[/if]-->
      </span>
      <input type="submit" value="submit">
    </form>
</fieldset>
<fieldset>
  <legend>&nbsp;Person&nbsp;information&nbsp;</legend>
  <TABLE width="100%">
    <TR bgcolor="#99CCCC">
      <TH width="5%">id</TH>
      <TH width="10%">province</TH>
      <TH width="10%">district</TH>
      <TH width="10%">tambon</TH>
      <TH width="5%">moo</TH>
      <TH width="10%">village</TH>
      <TH width="5%">house no.</TH>
      <TH width="5%">gender</TH>
      <TH width="10%">firstname</TH>
      <TH width="10%">lastname</TH>
      <TH width="5%"></TH>
    </TR>

  <!--[yppager show=page 
                   img_prev="modules/VoteDataCenter/pnimages/back.png"
                   img_next="modules/VoteDataCenter/pnimages/next.png"
                   rowcount=$pager.numitems 
                   limit=$pager.itemsperpage 
                   posvar=startnum 
                   shift=0 
  ]-->
  <!--[foreach from=$objectArray item=item]-->
      <TR bgcolor="<!--[cycle values='#FFFFFF,#E8EFF7']-->">
        <TD><!--[$item.id]--></TD>
        <TD><!--[$item.pro_name]--></TD>
        <TD><!--[$item.dis_name]--></TD>
        <TD><!--[$item.tam_name]--></TD>
        <TD><!--[$item.vil_moo]--></TD>
        <TD><!--[$item.vil_name]--></TD>
        <TD><!--[$item.hou_no]--></TD>
        <TD><!--[$item.gen_name]--></TD>
        <TD><!--[$item.firstname]--></TD>
        <TD><!--[$item.lastname]--></TD>
        <TD>
          <a target="_blank" href="<!--[pnmodurl modname='VoteDataCenter' type='admin' func='form' ctrl='Person' id=$item.id]-->">
            <img src="modules/VoteDataCenter/pnimages/pencil.png" />
          </a>
          <a href="<!--[pnmodurl modname='VoteDataCenter' type='admin' func='delete' ctrl='Person' id=$item.id forward=1 pro_id=$item.pro_id dis_id=$item.dis_id ]-->" 
             onclick="return confirm('Are you sure you want to delete?')"
          >
            <img src="modules/VoteDataCenter/pnimages/delete.png" />
         </a>
        </TD>
      </TR>
  <!--[/foreach]-->
  </TABLE>
  <!--[yppager show=page 
                   img_prev="modules/VoteDataCenter/pnimages/back.png"
                   img_next="modules/VoteDataCenter/pnimages/next.png"
                   rowcount=$pager.numitems 
                   limit=$pager.itemsperpage 
                   posvar=startnum 
                   shift=0 
  ]-->
</fieldset>

<!-- Map -->
<fieldset>
  <legend>&nbsp;Person&nbsp;Map&nbsp;</legend>
<body onload="initialize()">
  <div id="map_canvas"></div>
</body>

</fieldset><BR>




<BR>
</html>

